Skip to content

feat(csharp): add C# language template filters - #218

Merged
w4bremer merged 1 commit into
mainfrom
feat/csharp-filter
Jun 5, 2026
Merged

feat(csharp): add C# language template filters#218
w4bremer merged 1 commit into
mainfrom
feat/csharp-filter

Conversation

@w4bremer

@w4bremer w4bremer commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a filtercs package providing C# code-generation template filters, registered into the shared template FuncMap (pkg/gen/filters/funcmap.go) alongside the other supported languages.

The filters are pure model→string functions and are independent of any SDK template; a template opts in by calling {{ csReturn . }} and friends.

Filters

Function(s) Purpose
csReturn / csType C# type mapping
csDefault default value for a type
csParam / csParams Type name, comma-joined
csVar / csVars argument name(s)
csTestValue non-default value for round-trip tests
csAsyncReturn wraps the return type in Task<T> (Task for void)
csNs / csNsOpen / csNsClose block-scoped namespaces
csExtern / csExterns reads cs.namespace/cs.name/cs.default/cs.using/cs.package/cs.version meta

Type mapping

  • scalars → C# primitives (int, long, float, double, bool, string); bytesbyte[]; anyobject
  • arrays → List<T>
  • enums/structs → their name; interfaces → I-prefixed
  • async → Task<T>

Testing

Every filter is unit-tested in isolation against the shared pkg/gen/filters/testdata fixtures. The extern fixtures gain additive cs.* meta keys; other languages read only their own keys, so this is non-breaking.

  • go test ./... — all green
  • gofmt / go vet / staticcheck — clean

Add a filtercs package providing C# code-generation filters and register
them in the shared template FuncMap.

Functions: csReturn/csType, csDefault, csParam(s), csVar(s), csTestValue,
csAsyncReturn (Task<T>), csNs/csNsOpen/csNsClose (block namespaces), and
csExtern(s) reading cs.namespace/name/default/using/package/version meta.

Type mapping: scalars to C# primitives, arrays to List<T>, interfaces are
I-prefixed, async returns wrap in Task<T>, and namespaces are block-scoped.
Extern test fixtures gain additive cs.* meta keys.

The filters are unit-tested in isolation against the shared testdata
fixtures.
@w4bremer
w4bremer merged commit 2275d0b into main Jun 5, 2026
6 checks passed
@w4bremer
w4bremer deleted the feat/csharp-filter branch June 5, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant